package com.weixin.paleituo.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.weixin.paleituo.R;

/**
 * Author yichao
 * Time  2017/12/11 15:44
 * Dest  买房进度itemView
 */

public class ItemBuyHouseStepView extends LinearLayout {

    private LinearLayout mLinearLayout;
    private TextView mTvName, mTvContent;
    private View mViewLine;

    public ItemBuyHouseStepView(Context context) {
        this(context, null);
    }

    public ItemBuyHouseStepView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
        mLinearLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.item_buyhousestep_layout, this, true);
        mTvName = mLinearLayout.findViewById(R.id.tv_name_item_buyhousestep_layout);
        mTvContent = mLinearLayout.findViewById(R.id.tv_content_item_buyhousestep_layout);
        mViewLine = mLinearLayout.findViewById(R.id.view_item_buyhousestep_layout);
        TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.ItemBuyHouseStepView);

        String name = attributes.getString(R.styleable.ItemBuyHouseStepView_item_buyhouse_name);
        if (name != null && !name.equals("")) {
            mTvName.setText(name);
        }
        String detais = attributes.getString(R.styleable.ItemBuyHouseStepView_item_buyhouse_content);
        if (detais != null && !detais.equals("")) {
            mTvContent.setText(detais);
        }
        boolean isShowLine=attributes.getBoolean(R.styleable.ItemBuyHouseStepView_item_buyhouse_isshowline,true);
        if (!isShowLine){
            mViewLine.setVisibility(INVISIBLE);
        }
        attributes.recycle();
    }

    public ItemBuyHouseStepView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * 设置内容
     * @param tvContent
     */
    public void setTvContent(String tvContent){

        mTvContent.setText(tvContent);
        }

}
